var searchChartForm;
function createChartforCases(id,k,v,regioncode){

var arrestDrugStore = new Ext.data.Store({
	proxy : new Ext.data.HttpProxy({
				url : 'searchcharts.html',params:{id:id,type:k,regioncode:regioncode,searchdrugCode:searchdrugCode},
				method:'post'
			}),
	reader : new Ext.data.JsonReader({
				root : 'arrestchartModel',
				disableCaching:true,
				autoLoad : true
			}, [{
						name : 'monthName',
						mapping : 'monthName'
					},
					{
						name : 'numberArrest',
						mapping : 'numberArrest'
					},
					{
						name : 'numberCases',
						mapping : 'numberCases'
					},{
	                                            name: 'quantityDrug',
	                                            type: 'double'
	                                        }
			])
});

arrestDrugStore.load({params:{id:id,type:v+k,regioncode:regioncode,searchdrugCode:searchdrugCode}});

Ext.chart.Chart.CHART_URL = '/gis-addons/scripts/ext-3.4.0/resources/charts.swf';
arrestDrugStore.sort("monthName","ASC");

 if(k==0){
    
 searchChartForm =    new Ext.Panel({
        width: 250,
        height: 250,
       id:'searchdrugChart',
        title: chartTitle+' -'+ noArrestTitle+'/'+caseTitle+' -'+ YearWiseTitle ,
        items: {
            xtype: 'columnchart',
            store: arrestDrugStore,
          xField: 'monthName',
				 displayName: 'monthName',
           yAxis: new Ext.chart.NumericAxis({
                stackingEnabled: true
            }),
            series: [{
                yField: 'numberArrest',
                displayName: numberArrestTitle
            },{
                yField: 'numberCases',
                displayName: numberCasesTitle
            }]
        }
    });
 }else{
 searchChartForm =    new Ext.Panel({
        width: 250,
        height: 250,
       id:'searchdrugChart',
        title: chartTitle+' -'+drugTitle+quantityTitle+' -'+ YearWiseTitle ,
        items: {
            xtype: 'columnchart',
            store: arrestDrugStore,
          xField: 'monthName',
				 displayName: 'monthName',
           yAxis: new Ext.chart.NumericAxis({
                stackingEnabled: true
            }),
            series: [{
                yField: 'quantityDrug',
                displayName: quantityTitle+drugTitle
            }]
        }
    });
 }




/*searchChartForm = new Ext.FormPanel( {
	
        width: 150,
        height: 150,
        id:'searchdrugChart',
        //title:'Drug Comparison Chart',
        initComponent : function(config) {
        	Ext.apply(this,{
        		
        items: [
                
           {
        	//title:'Drug Comparison Chart',
            xtype: 'columnchart',
            store: arrestDrugStore,
            itemId: 'searchcompareChart',
            xField: 'monthName',
            yAxis: new Ext.chart.NumericAxis({
                    displayName: 'Cases-Arrests',
                    labelRenderer : Ext.util.Format.numberRenderer('0,0')
            }),
            
            series: [{
                type: 'column',
                displayName: 'No:Cases',
                yField: 'numberCases'
            }, {
                type: 'column',
                displayName: 'No:Arrest',
                yField: 'numberArrest'
            }],
            extraStyle: {
            		legend: {
            		display: 'bottom'
            		}
            		}
                     
           
            
        }]
    });

        	
}
});*/
searchChartForm = Ext.getCmp('searchdrugChart');
var winChart = Ext.getCmp('winChart');
if(winChart != null){

winChart.removeAll();
winChart.add(searchChartForm);
}
else{
 winChart = new Ext.Window({
        title: chartTitle,
        closable:true,
			id:'winChart',
        width:280,
        height:285,
        //border:false,
		
		

       // items: [nav, tabs]
	    items: [searchChartForm]
    });
}
winChart.doLayout();
		winChart.setPosition(800,200);

    winChart.show();

}

